package cn.yeziji.forum.controller;

import cn.yeziji.forum.bo.special.DetailSpecialDTO;
import cn.yeziji.forum.common.ForumResult;
import cn.yeziji.forum.dao.intf.ForumSpecialColumnDao;
import cn.yeziji.forum.utils.ForumResultUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 专栏控制器
 *
 * @author gzkemays
 * @date 2022/5/25
 */
@RestController
@RequestMapping("/special")
public class ForumSpecialController {
  @Resource ForumSpecialColumnDao specialDao;

  @GetMapping("/list")
  public ForumResult getSpecialList() {
    return ForumResultUtils.ok(specialDao.getSpecialsByUser());
  }

  @PostMapping("/save")
  public ForumResult saveSpecial(DetailSpecialDTO dto) {
    int save = specialDao.save(dto);
    if (save > 0) {
      return ForumResultUtils.ok();
    }
    return ForumResultUtils.error();
  }
}
